import React, { useEffect, useMemo, useState } from 'react';
import Cls from 'classnames';
import { Empty, Table } from 'antd';
import { openMaterielColumns } from '../mconfig';

const DetailInfoTableList: React.FC<any> = ({ dataList }) => {
  const [dataSource, setDataSource] = useState<any>([]);

  const columns: Record<string, any>[] = useMemo(() => {
    return openMaterielColumns(
      () => {},
      [],
      [],
      () => {},
      () => {},
      () => {},
      () => {},
      'detail',
      true,
    );
  }, [dataList]);

  useEffect(() => {
    dataList.length > 0 &&
      dataList.map((item) => {
        if (item.fuwu == 1) {
          dataSource.push(item);
        }
        setDataSource(dataSource);
      });
  }, [dataList]);

  return (
    <div style={{ width: '100%' }}>
      <div className={Cls('list-table', 'UpdatePackTable')}>
        {dataSource.length > 0 ? (
          <Table scroll={{ x: 1200, y: 160 }} bordered size="small" dataSource={dataSource} columns={columns} rowKey={'id'} pagination={false} />
        ) : (
          <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
        )}
      </div>
    </div>
  );
};

export default DetailInfoTableList;
